#include <stdio.h>
#include<stdlib.h>

void menuInterface()
{
    printf("1. 添加联系人\n");
    printf("2. 删除联系人\n");
    printf("3. 修改联系人\n");
    printf("4. 查找联系人\n");
    printf("5. 列出联系人\n");
}

#define BUFFER_SIZE 20

struct Person
{
    char name[BUFFER_SIZE];
    char phone[BUFFER_SIZE];
    char sex;
};

int main()
{
    int choice = 0;

    struct Person per[100];
    int count = 0;

    while (1)
    {
        menuInterface();
        
        printf("请输入你的选项：");
        scanf("%d", &choice);
        switch(choice)
        {
            case 1:
            {
                system("clear");

                printf("请输入联系人的姓名：");
                scanf("%s", per[count].name);

                printf("请输入联系人的号码：");
                scanf("%s", per[count].phone);
                getchar();
            
                printf("请输入联系人的性别：");
                scanf("%s", &per[count].sex);
                
                count++;
                printf("添加成功!\n");
                getchar();
                getchar();

                break;
            } 
            case 2:
                break;
            case 3:
                break;
            case 4:
                break;
            case 5:
                {
                    system("clear");
                    for (int idx = 0; idx < count; idx++)
                    {
                        printf("name:%s,\tphone:%s,\tsex:%c\n,", per[idx].name, per[idx].phone, per[idx].sex);
                    }
                    printf("按任意键退出...");
                    getchar();
                    getchar();
                    break;
                }
            default:
                break;
        }
        system("clear");
    }


    return 0;

}